package hn.sigit.model.hnd.administrative;

import hn.sigit.model.hnd.cadastre.HND_SpatialZone;
import hn.sigit.model.ladm.administrative.LA_AdministrativeSource;
import hn.sigit.model.ladm.external.ExtParty;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@org.hibernate.annotations.Proxy(lazy=false)
@Table(name="HND_Permit", schema="hnd_administrative")
@Inheritance(strategy=InheritanceType.JOINED)
public abstract class HND_Permit implements Serializable {
	private static final long serialVersionUID = -1746987211281763176L;
	
	private Long id;
	private Date requestDate;
	private Date issueDate;
	private Date validityFrom;
	private Date validityTo;
	private String requestText;
	private String ruleGroupName;
	private String cashiersCode;
	private BigDecimal payment;
	
	private String fieldVisitAssessment;
	private String environmentalAssessment;
	
	private Boolean approved;

	private String analystOpinion;
	private String approverOpinion;
	private String receptionistUserName;
	private String receptionistFullName;
	private String analystUserName;
	private String analystFullName;
	private String editorUserName;
	private String editorFullName;
	private String approverFullName;
	private String approverUserName;
	
	private ExtParty extParty;
	private HND_PermitRuleGroup ruleGroup;

	private HND_SpatialZone selectedZone;
	
	private Set<LA_AdministrativeSource> sources = new HashSet<LA_AdministrativeSource>();
	private Set<HND_PermitObservation> permitObservations = new HashSet<HND_PermitObservation>();

	
	@Id
	@Column(name="ID", nullable=false)
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="hnd_permit_id_gen")
	@SequenceGenerator(name="hnd_permit_id_gen", sequenceName="hnd_permit_id_seq", allocationSize=1)
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	
	@Column(name="RequestDate", nullable=false)
	public Date getRequestDate() {
		return requestDate;
	}
	public void setRequestDate(Date requestDate) {
		this.requestDate = requestDate;
	}
	
	@Column(name="IssueDate", nullable=true)
	public Date getIssueDate() {
		return issueDate;
	}
	public void setIssueDate(Date issueDate) {
		this.issueDate = issueDate;
	}
	
	@Column(name="ValidityFrom", nullable=false)
	public Date getValidityFrom() {
		return validityFrom;
	}
	public void setValidityFrom(Date validityFrom) {
		this.validityFrom = validityFrom;
	}
	
	@Column(name="ValidityTo", nullable=false)
	public Date getValidityTo() {
		return validityTo;
	}
	public void setValidityTo(Date validityTo) {
		this.validityTo = validityTo;
	}

	@Column(name="Approved", nullable=true)
	public Boolean getApproved() {
		return approved;
	}
	public void setApproved(Boolean approved) {
		this.approved = approved;
	}
	
	@Column(name="RequestText", nullable=true)
	public String getRequestText() {
		return requestText;
	}
	public void setRequestText(String requestText) {
		this.requestText = requestText;
	}
	
	@Column(name="RuleGroupName", nullable=true)
	public String getRuleGroupName() {
		return ruleGroupName;
	}
	public void setRuleGroupName(String ruleGroupName) {
		this.ruleGroupName = ruleGroupName;
	}

	@Column(name="CashiersCode", nullable=true)
	public String getCashiersCode() {
		return cashiersCode;
	}
	public void setCashiersCode(String cashiersCode) {
		this.cashiersCode = cashiersCode;
	}
	
	@Column(name="Payment", nullable=true, precision=19, scale=4)
	public BigDecimal getPayment() {
		return payment;
	}
	public void setPayment(BigDecimal payment) {
		this.payment = payment;
	}
	
	@Column(name="FieldVisitAssessment", nullable=true)
	public String getFieldVisitAssessment() {
		return fieldVisitAssessment;
	}
	public void setFieldVisitAssessment(String fieldVisitAssessment) {
		this.fieldVisitAssessment = fieldVisitAssessment;
	}
	
	@Column(name="EnvironmentalAssessment", nullable=true)
	public String getEnvironmentalAssessment() {
		return environmentalAssessment;
	}
	public void setEnvironmentalAssessment(String environmentalAssessment) {
		this.environmentalAssessment = environmentalAssessment;
	}

	@Column(name="AnalystOpinion", nullable=true)
	public String getAnalystOpinion() {
		return analystOpinion;
	}
	public void setAnalystOpinion(String analystOpinion) {
		this.analystOpinion = analystOpinion;
	}
	
	@Column(name="ApproverOpinion", nullable=true)
	public String getApproverOpinion() {
		return approverOpinion;
	}
	public void setApproverOpinion(String approverOpinion) {
		this.approverOpinion = approverOpinion;
	}
	
	@Column(name="ReceptionistUserName", nullable=true)
	public String getReceptionistUserName() {
		return receptionistUserName;
	}
	public void setReceptionistUserName(String receptionistUserName) {
		this.receptionistUserName = receptionistUserName;
	}
	
	@Column(name="ReceptionistFullName", nullable=true)
	public String getReceptionistFullName() {
		return receptionistFullName;
	}
	public void setReceptionistFullName(String receptionistFullName) {
		this.receptionistFullName = receptionistFullName;
	}
	
	@Column(name="AnalystUserName", nullable=true)
	public String getAnalystUserName() {
		return analystUserName;
	}
	public void setAnalystUserName(String analystUserName) {
		this.analystUserName = analystUserName;
	}
	
	@Column(name="AnalystFullName", nullable=true)
	public String getAnalystFullName() {
		return analystFullName;
	}
	public void setAnalystFullName(String analystFullName) {
		this.analystFullName = analystFullName;
	}
	
	@Column(name="EditorUserName", nullable=true)
	public String getEditorUserName() {
		return editorUserName;
	}
	public void setEditorUserName(String editorUserName) {
		this.editorUserName = editorUserName;
	}
	
	@Column(name="EditorFullName", nullable=true)
	public String getEditorFullName() {
		return editorFullName;
	}
	public void setEditorFullName(String editorFullName) {
		this.editorFullName = editorFullName;
	}
	
	@Column(name="ApproverUserName", nullable=true)
	public String getApproverUserName() {
		return approverUserName;
	}
	public void setApproverUserName(String approverUserName) {
		this.approverUserName = approverUserName;
	}
	
	@Column(name="ApproverFullName", nullable=true)
	public String getApproverFullName() {
		return approverFullName;
	}
	public void setApproverFullName(String approverFullName) {
		this.approverFullName = approverFullName;
	}

	@ManyToOne(targetEntity=ExtParty.class, fetch=FetchType.LAZY)
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})	
	@JoinColumns({ @JoinColumn(name="ExtPartyID", referencedColumnName="ID") })
	@org.hibernate.annotations.LazyToOne(value=org.hibernate.annotations.LazyToOneOption.NO_PROXY)	
	public ExtParty getExtParty() {
		return extParty;
	}
	public void setExtParty(ExtParty extParty) {
		this.extParty = extParty;
	}
	
	@ManyToOne(targetEntity=HND_SpatialZone.class, optional=false, fetch=FetchType.LAZY)
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})
	@JoinColumns({ @JoinColumn(name="SelectedZoneID", referencedColumnName="LA_SpatialUnitID") })
	@org.hibernate.annotations.LazyToOne(value=org.hibernate.annotations.LazyToOneOption.NO_PROXY)
	public HND_SpatialZone getSelectedZone() {
		return selectedZone;
	}
	public void setSelectedZone(HND_SpatialZone selectedZone) {
		this.selectedZone = selectedZone;
	}
	
	@ManyToOne(targetEntity=HND_PermitRuleGroup.class, fetch=FetchType.LAZY)
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})	
	@JoinColumns({ @JoinColumn(name="HND_PermitRuleGroupID", referencedColumnName="ID") })	
	@org.hibernate.annotations.LazyToOne(value=org.hibernate.annotations.LazyToOneOption.NO_PROXY)	
	public HND_PermitRuleGroup getRuleGroup() {
		return ruleGroup;
	}
	public void setRuleGroup(HND_PermitRuleGroup ruleGroup) {
		this.ruleGroup = ruleGroup;
	}


	@OneToMany(targetEntity=LA_AdministrativeSource.class, fetch=FetchType.LAZY)
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN})	
	@org.hibernate.annotations.LazyCollection(org.hibernate.annotations.LazyCollectionOption.TRUE)
	public Set<LA_AdministrativeSource> getSources() {
		return sources;
	}
	public void setSources(Set<LA_AdministrativeSource> sources) {
		this.sources = sources;
	}


	@OneToMany(targetEntity=HND_PermitObservation.class, fetch=FetchType.LAZY)
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN})	
	@org.hibernate.annotations.LazyCollection(org.hibernate.annotations.LazyCollectionOption.TRUE)
	public Set<HND_PermitObservation> getPermitObservations() {
		return permitObservations;
	}
	public void setPermitObservations(Set<HND_PermitObservation> permitObservations) {
		this.permitObservations = permitObservations;
	}
}
